
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- Crea vista relacion_persona
-- drop view relacion_persona

CREATE VIEW [dbo].[relacion_persona] AS
SELECT	CASE a.Sexo
			WHEN 1 THEN 'F'
			WHEN 2 THEN 'M'
		END AS pers_sexo,
		a.Documento AS pers_documento,
		CASE fc.Sexo
			WHEN 1 THEN 'F'
			WHEN 2 THEN 'M'
		END AS pers_sexo_rel,
		fc.Documento AS pers_documento_rel,
		fc.Parentezco AS tab_relacion_id,
		fc.FechaCasamiento AS rel_pers_fecha_desde,
		fc.ACargo AS rel_pers_acargo,
		fc.CorrespondeAsignacionFamiliar AS rel_pers_salario_familiar
FROM tb_familiaresACargo fc, tb_Agentes a
WHERE	a.idAgente = fc.idAgente 
GO
